<template>
    <el-form-item :label="label">
        <el-radio-group v-model="value" v-bind="sonAttrs">
            <component :is="tag" v-for="item in sonAttrs.options"
             :key="item.value" :value="item.value" :label="item.label"/>
        </el-radio-group>
    </el-form-item>
</template>
<script setup lang="ts">
import {computed,useAttrs } from 'vue'
const value = defineModel()
const attrs = useAttrs()
const {label} = defineProps<{
    label:string
}>()
const tag = computed(()=>{
    return attrs.type === 'button'?'el-radio-button':'el-radio'
})
type options = {value:string,label:string}[];
type attrsType = {[key:string]:any,options?:options}
const sonAttrs = computed<attrsType>(()=>{
    let attr = {...attrs}
    if(!('options' in attr))attr['options'] = []
    return attr
})
</script>